////////////////////////////////////////
// stringUtil.cpp
/* Name: Stephen Durfey
 * Class: cs335
 * Prof: Dr. Michael Poor
 * Due Date: October 17, 2008
 ****************************************/

#include "stringUtil.h"
#include "StringTable.h"
using namespace std;

////////////////////////////////////////
// 'readMultiWord' reads a multiword string
//     terminated by 'sep' from 'infile' into 's';
// returns true if a multiword string read;
// returns false if the first word is a separator ('sep')
// Example: if 'infile' contains "Los Angeles # California"
//     then "Los Angeles" is stored in 's' and
//     position of 'infile' is now at "California"

bool readMultiWord(string & s, istream & inData, const string & sep)
{
    string  w;

    inData >> s;
    if (s == sep)
        return false;
    inData >> w;
    while (w != sep)
    {
        s += " " + w;
        inData >> w;
    }
    return true;
}

void displaySelected(const vector<string> &vectString, vector<int> &vectInt)
{
    for(unsigned int index = 0; index < vectInt.size(); ++index)
    {
        cout << left << setw(15) << vectString[vectInt[index]];
    }
    cout << endl;
}

float stringToFloat(const string &s)
{
    stringstream ss;
    float val;
    ss << s;
    ss >> val;
    ss.clear();
    return val;
}


